//
//  UIButton+Mixing.m
//  LocalGoods2
//
//  Created by Feihong Ye on 2018/10/23.
//  Copyright © 2018年 Xiaodong Huang. All rights reserved.
//

#import "UIButton+Mixing.h"

@implementation UIButton (Mixing)

- (void)buttonMixingImagePictureLocation:(PictureLocation)pictureLocation spacing:(CGFloat)spacing {
    switch (pictureLocation) {
        case pictureLocationLeft:
            self.titleEdgeInsets = UIEdgeInsetsMake(0, 12, 0, 0);
            break;
        case pictureLocationRight:
            // button标题的偏移量
            self.titleEdgeInsets = UIEdgeInsetsMake(0, -self.imageView.bounds.size.width-spacing, 0, self.imageView.bounds.size.width);
            // button图片的偏移量
            self.imageEdgeInsets = UIEdgeInsetsMake(0, self.titleLabel.bounds.size.width, 0, -self.titleLabel.bounds.size.width);

            break;
        case pictureLocationTop:
            self.titleEdgeInsets = UIEdgeInsetsMake(self.imageView.frame.size.height-spacing, -self.imageView.bounds.size.width, 0,0);
            self.imageEdgeInsets = UIEdgeInsetsMake(0, self.titleLabel.frame.size.width/2, self.titleLabel.frame.size.height, -self.titleLabel.frame.size.width/2);
            break;
        case pictureLocationBottom:
            
            break;
        default:
            break;
    }
    
}

@end
